package com.demo.gulimall.auth.controller;

import com.demo.gulimall.auth.entity.MemberReceiveAddress;
import com.demo.gulimall.auth.service.MemberReceiveAddressService;
import com.demo.gulimall.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Chen Yuan
 * @create 2023-06-26  16:42
 */
@RestController
@RequestMapping("/member/address")
public class MemberReceiveAddressController {

	@Autowired
	private MemberReceiveAddressService memberReceiveAddressService;

	@GetMapping("/get")
	public R<List<MemberReceiveAddress>> getAddress(@RequestParam("userId") Long userId){
		List<MemberReceiveAddress> memberAddresses = memberReceiveAddressService.getAddressByUserId(userId);
		return R.ok(memberAddresses);
	}


	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	//@RequiresPermissions("member:memberreceiveaddress:info")
	public R<MemberReceiveAddress> info(@PathVariable("id") Long id){
		MemberReceiveAddress memberReceiveAddress = memberReceiveAddressService.getById(id);
		return R.ok(memberReceiveAddress);
	}
}
